package com.example.mobile2021606127cxz0617homework;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;


import java.util.ArrayList;
import java.util.List;

public class RVAdapter extends RecyclerView.Adapter<RVAdapter.MyViewHolder> {
    List<Infor> list = new ArrayList<>();

    public RVAdapter(List<Infor> list) {
        this.list = list;
    }


    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_infor, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull RVAdapter.MyViewHolder holder, int position) {
        Infor infor = list.get(position);
        holder.name.setText(infor.getName());
        holder.skill.setText(infor.getSkill());
        holder.xinchou.setText(String.valueOf(infor.getXinchou()));


    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        TextView name, skill, xinchou;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.tv_main_name);
            skill = itemView.findViewById(R.id.tv_main_skill);
            xinchou = itemView.findViewById(R.id.tv_main_xinchou);
        }
    }
}
